﻿// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

//using DotNetFramework.CAP.Transport;
//using Microsoft.Extensions.Options;

using DotNetFramework.CAP.Abstractions;

namespace DotNetFramework.CAP.Kafka
{
    public class KafkaConsumerClientFactory : IConsumerClientFactory
    {
        private readonly KafkaOptions _kafkaOptions;
        IContentSerializer _serializer;

        public KafkaConsumerClientFactory(KafkaOptions kafkaOptions, IContentSerializer serializer)
        {
            _kafkaOptions = kafkaOptions;
            _serializer = serializer;
        }

        public virtual IConsumerClient Create(string groupId)
        {
            try
            {
                return new KafkaConsumerClient(groupId, _kafkaOptions,_serializer);
            }
            catch (System.Exception e)
            {
                throw new BrokerConnectionException(e);
            }
        }
    }
}